#ifdef NOT_IN_PROJ
//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#include <model/particletemplate.h>
#include <model/root.h>
#include "attrevent.h"
#include "ptview.h"
#include "docevents.h"
#include "viewattributes.h"
using namespace model;
//
PtView::PtView(QWidget *parent) : QWidget(parent), pt(NULL) {
   widget.setupUi(this);
   handle_set_attr_group();
}
PtView::~PtView() {
}
void PtView::handle_set_attr_group() {
   if (get_document() != 0) {
      setEnabled(true);
      refresh_cached_attrs();
      redraw_all();
   } else {
      setEnabled(false);
   }
}
void PtView::handle_doc_event(DocEvent* event) {
   switch (event->type) {
   case DocEvent::particle_template_name_changed:
   {
      //DocEvents::NewParticleTemplate *ev = static_cast<DocEvents::NewParticleTemplate*>(event);
      //..
      break;
   }
   case DocEvent::particle_template_visible_changed:
   {
      break;
   }
   case DocEvent::something:
      redraw_all();
   }
}
void PtView::handle_attr_event(AttrEvent *evnt) {
   if (!get_document())
      return;
   switch(evnt->get_type()) {
   case AttrEvent::value_changed:
   {
      AttrValueChanged *avc = static_cast<AttrValueChanged*>(evnt);
      /*if (avc->get_name() == selected_particle_template) {
         pt = ViewAttributeType::ParticleTemplate::lookup(get_attr_group(), selected_particle_template)->get_pt();
         redraw_all();
         break;
      }*/
   }
   }
}
void PtView::redraw_all()
{
   if (pt) {
      widget.pt_name->setText(pt->get_name());
      widget.pt_visible->setChecked(pt->get_visible());
   } else {
      //unnecessary?
      widget.pt_name->setText(QString());
      widget.pt_visible->setChecked(false);
   }
}
void PtView::refresh_cached_attrs() {
   if (!get_document()) {
      pt = NULL;
      return;
   }
   //pt = ViewAttributeType::ParticleTemplate::lookup(get_attr_group(), selected_particle_template)->get_pt();
   pt=0;
}
#endif
